package com.ll.notice.Utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateTimeUtils {
    public static String today(String pattern) {
        if (pattern == null) {
            throw new IllegalArgumentException("日期格式不能为空");
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        String dt = sdf.format(new Date());
        return dt;
    }

    public static String nowTime() {
        return today("yyyy/MM/dd HH:mm:ss");
    }

    public static String todayAdd15(String pattern) {
        if (pattern == null) {
            throw new IllegalArgumentException("日期格式不能为空");
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        Date date = new Date();
        date.setTime(date.getTime() + 15*60*1000);
        String dt = sdf.format(date);
        return dt;
    }

    public static String nowTimeAdd15() {
        return todayAdd15("yyyy/MM/dd HH:mm:ss");
    }
    public static void main(String[] args){
        System.out.println(nowTimeAdd15());
    }
}
